/**
 * @Author: 胡雄柏
 * @Description: 用于vue项目引入外部css文件
 * @CreateDate: 2020/10/15 13:29
 * @UpdateDate: 2020/10/15 13:29
 */

// 导入外部css的组件
import Vue from 'vue';

Vue.component('remote-link', {
  render: function(createElement) {
    var self = this;
    return createElement('link', {
      attrs: {
        rel: 'stylesheet',
        href: this.href
      },
      on: {
        load: function(event) {
          self.$emit('load', event);
        },
        error: function(event) {
          self.$emit('error', event);
        },
        readystatechange: function(event) {
          if (this.readyState === 'complete') {
            self.$emit('load', event);
          }
        }
      }
    });
  },
  props: {
    href: {
      type: String,
      required: true
    }
  }
});
